package com.r2coding.music.api;

import com.github.pagehelper.PageInfo;
import com.r2coding.common.util.Result;
import com.r2coding.music.entity.MvEntity;
import com.r2coding.music.service.MvService;
import com.r2coding.music.vo.req.QueryMvListReqVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author:98k灬
 * @since:2022/05/08 20:14
 **/
@RestController
@RequestMapping("/api/mv")
public class ApiMvController {
    @Autowired
    MvService mvService;

    /**
     * 分页查询MV列表
     *
     * @param reqVo 请求
     * @return 统一响应体
     */
    @PostMapping("/list")
    public Result list(@RequestBody QueryMvListReqVo reqVo) {
        PageInfo<MvEntity> page = mvService.selectList(reqVo);
        return Result.ok(page);
    }

    @PostMapping("/clientList")
    public Result clientList(@RequestBody QueryMvListReqVo reqVo) {
        reqVo.setStatus(1);
        PageInfo<MvEntity> page = mvService.selectList(reqVo);
        return Result.ok(page);
    }

    /**
     * 根据mv的id查询MV的详情
     *
     * @param id mv的id
     * @return 统一响应体
     */
    @GetMapping("/info/{id}")
    public Result info(@PathVariable("id") Integer id) {
        MvEntity mv = mvService.getById(id);
        return Result.ok(mv);
    }

    /**
     * 获取推荐MV
     *
     * @return 统一响应体
     */
    @GetMapping("/getRecommend")
    public Result reCommend() {
        List<MvEntity> mvs = mvService.getRecommend();
        return Result.ok(mvs);
    }
}
